/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package doc2db.interfaces.mainWindow.action;

import doc2db.interfaces.mainWindow.MyPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author yura
 */
public class FileChousAction implements ActionListener{
    private MyPanel pane;

    public FileChousAction(MyPanel p){
        pane = p;
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new File("."));
        String[] extensions = new String[] {"doc", "DOC"};
        chooser.setFileFilter(new FileNameExtensionFilter("Microsoft Word document", extensions));

        int r = chooser.showOpenDialog(/*this*/new JFrame("null"));
        
        if (r == JFileChooser.APPROVE_OPTION) {
            pane.file.setText(chooser.getSelectedFile().getAbsolutePath());
        }
    }

}
